home *** CD-ROM | disk | FTP | other *** search
- /* Kriegspiel written by David Wolfe based on a program by Bert Enderton
- May 5, 1986
-
- Network interface modified by Steve Schoch <schoch@ames.arpa>
- */
-
- #ifndef lint
- static char rcsid[] = "$Header: main.c,v 1.3 87/05/19 17:23:17 schoch Exp $";
- #endif
-
- /* main.c */
- #include "externs.h"
- #include <ctype.h>
- #include <signal.h>
- #include <strings.h>
-
- char symbol [7] = { '-', 'P', 'K', 'N', 'B', 'R', 'Q' };
- u_char whose [100];
- u_char occupant [100];
- char *colorname [2] = { "white", "black" };
- int pawndir [2] = { -10, 10 };
-
- LIST dirlist [7];
- LIST piecelocs [2];
- int kingloc [2];
- MOVELIST movelist = (MOVELIST) NULL;
- u_char ourcolor = UNSET;
- u_char theircolor;
- int lastmovefrom = 0;
- int lastmoveto = 0;
- u_char virgin [100];
- bool drawok [2] = { FALSE, FALSE};
- bool resign = FALSE;
- bool dead = FALSE;
- u_char color=WHITE, state=PLAYING;
- u_char option [NOPTIONS];
- WINDOW *blanksq [89];
- WINDOW *square [89];
- WINDOW *win [23];
- WINDOW *backupwin [23];
- WINDOW *backupscreen;
- WINDOW *blankscreen;
- char sqcolor [2];
- bool vtterm;
- bool dumbterm = FALSE;
- bool reversescr;
- int sqheight;
- int sqwidth;
- bool reverse = FALSE;
- bool iamserver = UNSET;
- FILE *inp, *out;
- long random();
-
- main (argc, argv, envp)
- int argc;
- char **argv, **envp;
- {
- int i, j, port = 0, trap_sigint();
- char *p, *malloc ();
- long time ();
-
- signal (SIGINT, SIG_IGN);
- signal (SIGPIPE, SIG_IGN);
- srandom (time((long *) NULL));
- if (!strcmp (argv [1], "help")) {
- execle(PRINT_FILE, PRINT_FILE,
- HELP_FILE, 0, envp);
- perror ("execle");
- exit (1);
- }
- if (argc <= 1) {
- printf ("Usage: %s [-bwcaprsdh] user\n", argv[0]);
- printf ("Or for help: %s help\n", argv[0]);
- exit (0);
- }
- for (i = 0; i < NOPTIONS; i++)
- option [i] = UNSET;
- j = 0;
- for (i = 1; i < argc - 1; i++) {
- j = TRUE;
- for (p = argv [i]; *p != '\000'; p++) {
- if isupper (*p)
- *p = tolower (*p);
- if (*p == '-')
- j = FALSE;
- else if (*p == 'b')
- option [COLOR] = BLACK;
- else if (*p == 'w')
- option [COLOR] = WHITE;
- else if (*p == 'c')
- option [COLOR] = RANDOM;
- else if (*p == 'a')
- option [ANNOUNCETAKES] = j;
- else if (*p == 'p')
- option [ANNOUNCEPAWNS] = j;
- else if (*p == 'r')
- reverse = TRUE;
- else if (*p == 's')
- iamserver = j;
- else if (*p == 'd')
- dumbterm = j;
- else if (isdigit (*p))
- port = port * 10 + (*p - '0');
- else if (*p == 'h') {
- execle(PRINT_FILE, PRINT_FILE,
- HELP_FILE, 0, envp);
- perror ("execle");
- exit (1);
- }
- }
- }
- initdirlists ();
- initpiecelocs ();
- initscreen ();
- refresh();
- redraw();
- signal (SIGINT, trap_sigint);
- p = argv [argc - 1];
- message("Connecting...", MESSAGE);
- refresh ();
- connectport (p, port);
- mclear(MESSAGE);
- message("type help for\nsample commands", MESSAGE);
- refresh ();
- dooptions();
- if (ourcolor == WHITE) {
- message("--- WHITE ---", MYCOLOR);
- reverse = 0;
- } else
- message("--- BLACK ---", MYCOLOR);
- initboard (FALSE);
- movecycle ();
- }
-